<template>
          <div class="layerRtb layerRtb-threecolumn layerRtb-right">
            <three-title :title="{name:'综合'}" :close="false">
                <span tag="i" class="rig_close fr" @click="$parent.$parent.clickFourShow()"></span>
            </three-title>
        <!-- <div class="mb10 fr mr10">
            <span class="mr10">选择日期</span>
                <el-date-picker v-model="dateValue" type="date" format="yyyy/MM" placeholder="选择日期" @change="dataChange"></el-date-picker>
        </div> -->
        <div class="layerRtb-scroll thinScroll" v-scrollHeight="437" v-if="downgrade.length>0">
            <div class="analyItem"  v-for="(item,index) in downgrade" :key="index">
                <p class="analyItemTit tx-center">降级-{{index+1}}</p>
                <div class="analyItemCon">
                    <p class="col-md-6">时间：
                        <span class="cLightGray pr8">{{item.createTime}}</span>
                    </p>

                    <p class="col-md-6">积分：
                        <span class="cLightGray pr8">{{item.scope}}</span>
                    </p>
                     <p class="col-md-12">内容：
                         <span class="cLightGray pr8">{{item.description}}</span>
                    </p>
                </div>
            </div>
        </div>
        <div class="layerRtb-scroll thinScroll" v-scrollHeight="0" v-else>
                <div class="analyItem">
                    <p class="analyItemTit tx-center">降级</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>暂无内容！</span>
                        </p>
                    </div>
                </div>
        </div>
        <div class="layerRtb-footer">
             <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                 <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>总数：</span>
                            <span>{{downgrade.length}}</span>
                        </p>
                    </div>
            </div>
        </div>
    </div>
</template>
<script>
import { mapGetters } from 'vuex'
import { complaintsIntegralHistory, findDowngradeHistory } from '../../../Resources/Api/index'
export default {
    data () {
        return {
            refundUser: [],
            dateValue: '',
            tIntegral: 0,
            tIntegralObject: [],
            downgrade: []
        }
    },
    created () {
        this.getDowngradeHistory()
    },
    methods: {
        getDowngradeHistory () {
            let _this = this
            _this.downgrade = []
            findDowngradeHistory({
                uid: this.leftInfo.uid
            }).then(result => {
                _this.downgrade = result.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        GetDeposit () {
            let _this = this
            _this.refundUser = []
            complaintsIntegralHistory({
                uId: _this.leftInfo.uid,
                cuurentMonth: this.$utils.format('yyyy-MM', this.dateValue)
            }).then(results => {
                _this.refundUser = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },
        clickFourShow (index) {
            this.fourIndex = index
        },
        dataChange () {
            this.GetDeposit()
        }
    },
    computed: {
        ...mapGetters(['leftInfo']),
        compluedTask () {
            return this.refundUser.map(item => item.haPenalty).reduce((acc, cur) => (cur + acc), 0)
        }
    },
    watch: {
        leftInfo () {
            this.getDowngradeHistory()
        }
    }
}
</script>
